Software vulnerabilities detection system and methods

ABSTRACT

This invention teaches a system and methods of detecting software vulnerabilities in a computer program by analyzing the compiled code and optionally the source code of the computer program. The invention models compiled software to examine both control flow and dataflow properties of the target program. A comprehensive instruction model is used for each instruction of the compiled code, and is complemented by a control flow graph that includes all potential control flow paths of the instruction. A data flow model is used to record the flow of unsafe data during the execution of the program. The system analyzes the data flow model and creates a security finding corresponding to each instruction that calls an unsafe function on unsafe data. These security findings are aggregated in a security report along with the corresponding debug information, any ancillary information, remediation recommendations and the optional source code information for each instruction that triggered the security finding.

GOVERNMENT LICENSE RIGHTS

This invention was made with government support under the CyberFastTrackprogram documented in DARPA PA-11-53 dated Jan. 31 2013, awarded byDefense Advanced Research Projects Agency (DARPA).

FIELD OF THE INVENTION

This invention relates generally to ensuring software security and inparticular to exposing software vulnerabilities by performing static anddynamic analysis of compiled software.

BACKGROUND ART

Software security and vulnerability checking is an active field ofacademic and industrial pursuit. With the news of exploitation ofsoftware vulnerabilities by hackers a commonplace occurrence, it isunsurprising to see many academic and professional institutions focusingtheir efforts to develop tools and practices that aim to make softwaremore secure against exploitative attacks from global hackers andadversaries.

There are many ways of detecting and addressing vulnerabilities insoftware in the prior art. U.S. Pat. No. 8,499,353 discloses securityassessment and vulnerability testing of software applications based inpart on application metadata in order to determine an appropriateassurance level and associated test plan that includes multiple types ofanalysis. Steps from each test are combined into a “custom” or“application-specific” workflow, and the results of each test thencorrelated with other results to identify potential vulnerabilities.

U.S. Pat. No. 8,365,155 describes a software analysis frameworkutilizing a decompilation method and system for parsing executable code,identifying and recursively modeling data flows, identifying andrecursively modeling control flow and iteratively refining these modelsto provide a complete model at the nanocode level. The nanocodedecompiler may be used to determine flaws, security vulnerabilities, orgeneral quality issues that may exist in the code.

U.S. Pat. No. 8,739,280 describes a context-sensitive taint analysissystem. Taint processing applied to a tainted value of an application isidentified and an output context of the application associated withoutput of the tainted value is determined. It is determined whether thetaint processing is effective in mitigating a security vulnerabilitycaused by the tainted value for the output context.

U.S. Pat. No. 8,347,392 describes an apparatus and method for analyzingand supplementing a program to provide security. A computer readablestorage medium has executable instructions to perform an automatedanalysis of program instructions. The automated analysis includes atleast two analyses selected from an automated analysis of injectionvulnerabilities, an automated analysis of potential repetitive attacks,an automated analysis of sensitive information, and automated analysisof specific HTTP attributes. Protective instructions are inserted intothe program instructions. The protective instructions are utilized todetect and respond to attacks during execution of the programinstructions.

Non-Patent reference, “Dynamic Taint Analysis for Automatic Detection,Analysis” by James Newsome and Dawn Song of Carnegie Mellon University,proposes a dynamic taint analysis solution for automatic detection ofoverwrite attacks. The approach does not need source code or specialcompilation for the monitored program, and hence works on commoditysoftware. To demonstrate this idea, they implemented TaintCheck, amechanism that can perform dynamic taint analysis by performing binaryrewriting at run time.

Non-Patent reference, “gFuzz: An instrumented web application fuzzingenvironment” by Ezequiel D. Gutesman of Core Security Technologies,Argentina, introduces a fuzzing solution for PHP web applications thatimproves the detection accuracy and enriches the information provided invulnerability reports. They use dynamic character-grained taint analysisand grammar-based analysis in order to analyze the anatomy of eachexecuted SQL query and determine which resulted in successful attacks. Avulnerability report is then accompanied by the offending lines ofsource code and the fuzz vector (with attacker-controlled charactersindividualized).

One shortcoming of prior art teachings is that they suffer from pooraccuracy while also at times requiring source code for analysis asopposed to just bytecode/assembly code, or they attempt to simplify thebytecode/assembly code before analysis. Other prior art work teachesrunning both dynamic and static analysis components in an independent orserial fashion. Furthermore earlier approaches attempt to exhaustivelymap all data flows in a decompiled or intermediate representation of asoftware system which impairs performance and slows the overall process.Relatedly, prior art teachings do not provide for advantages afforded byconcurrent multi-core or multi-CPU processing infrastructure that iscommonplace these days, to allow for distributed analysis of very largetarget software systems with high precision.

OBJECTS OF THE INVENTION

In view of the shortcomings of the prior art, it is an object of thepresent invention to provide for high-precision software analysis systemand methods that do not require the source code of the analyzed program.

It is another object of the invention to not require an exhaustiveprocessing of all dataflows in a program but rather than the ones thatinclude unsafe data.

It is another object of the invention to not rely on decompliation ofexecutable binary code.

It is yet another object of the invention to allow for distributedprocessing of the analysis framework taught by the invention by takingadvantage of a multi-CPU or multi-core processing environment,consequently allowing for analysis of very large target software systemswith efficiency and high precision.

SUMMARY OF THE INVENTION

The objects and advantages of the invention are secured by a system andmethods of detecting software vulnerabilities in a computer program byanalyzing the compiled code of that computer program. The inventionoptionally uses the source code of the computer program in conjunctionwith the compiled code, but having the source code is not a requirementof the invention. The invention teaches utilizing an instruction modelfor each binary instruction of the compiled code. The instruction modelfor a given instruction includes the location, debug information,instruction type, operands, existing memory state requirements, bytecodemetadata, potential security attributes, basic block membership andfunction/method membership if applicable of that instruction.

The invention further uses a control flow graph for each instructionthat complements the instruction model of that instruction, and includesall potential control flow paths, and a bidirectional list ofpredecessor instructions of that instruction. Preferably, the compiledcode is instrumented at random and critical points in the code. There isa data flow model to record the flow of unsafe data during the executionof the program. The system has the means to analyze the data flow modeland create a security finding corresponding to each instruction thatcalls an unsafe function on unsafe data. These security findings areaggregated in a security report along with the corresponding debuginformation and the optional source code information for eachinstruction that triggered the security finding.

In the preferred embodiment of the invention, the instruction model alsoincludes placeholders for additional attributes. These additionalattributes may include information for pointer aliases or unsafedataflow. The pointer alias information may include an aliasing mapcontaining pointers that have the same address values given a subset ofor all possible control flows of the instructions of the compiled code.

In another embodiment, the instruction model also contains attributesthat are deduced from other attributes of the instruction model. Thesederived attributes may include values for memory locations, processorregisters and variable types associated with the given instruction ofthe instruction model. In another preferred embodiment, the flow ofunsafe data is recorded in a data flow file that utilizes a common fileformat such as XML, based on which the data flow model is at leastpartially populated. In an advantageous embodiment of the invention, ananalyzer module is used to analyze the instruction model, control flowgraph and the data flow model to detect software vulnerabilities in thecompiled code.

In a highly advantageous embodiment of the invention, a set ofconcurrent worker threads are spawned that take advantage of amulti-core or multi-node or multi-machine or multi-CPU processingplatform, to analyze instructions where an unknown or unsafe externalinput (or taint) data is provided to the program and an unsafe functionor method is called upon it. In another preferred embodiment of thesystem, the security findings in the security report also contain a fulltrace of the unsafe data at the instruction that triggered the securityfinding, along with the line numbers of the source file if available, ahuman-readable description of the finding, a risk rating and optionallyone or more recommendations to address the security finding.

The methods of the invention further teach the steps required to carryout the operation of the system. The invention teaches the stepsrequired to detect software vulnerabilities of a computer program bytaking as input the compiled code of the program, and optionally itssource code. It then creates an instruction model and a control flowgraph for each instruction in the compiled code. If further creates adata flow model to record the flow of unsafe data during the executionof the compiled code. The compiled code is instrumented at random andcritical control flow points of the program.

For a given instruction, the instruction model includes the location,debug information, instruction type, operands, existing memory staterequirements, bytecode metadata, potential security attributes, basicblock membership, function/method membership if applicable and classmembership of the given instruction. The instruction model also includesplaceholders for additional attributes, including pointer aliasinginformation, unsafe data flow information and attributes that arededuced from other attributes including values of memory locations,values of processor registers and variable types for the giveninstruction.

For each instruction, the control flow graph is populated with allpotential control flow paths, and a bidirectional list of predecessorinstructions. Finally, for each instruction, the data flow model ispopulated by running the compiled code with the instrumentation at leastonce and recording the flow of unsafe data for each run. In anotherpreferred embodiment, this recording of unsafe data flow is first donein a data flow file in a common file format such as XML, and thepopulation of the data flow model is based on the data flow file.

The compiled code is scanned according to the methods claimed by theinvention to find each instruction where an external input is suppliedto the program, denoting unknown, unsafe data. If that instruction callsan unsafe function on the unsafe data, this triggers the creation of asecurity finding. As the analysis is performed, all security findingsare aggregated in a security report. In the preferred embodiment, eachsecurity finding in the security report includes the debug informationfor the instruction that triggered the finding, along with the linenumbers of the source code if available, a trace of the unsafe data fromits origin to termination, identifier values of any processor registersor variables containing the unsafe data, a description of the securityfinding, a risk rating, and optionally one or more recommendations toaddress or remedy the security finding. Appropriate highlighting ofthese elements in the security report is also performed to make thereport visually presentable, readable and easy to consume.

In another advantageous embodiment, three lists are created for eachinstruction. These lists are Unsafe1, Unsafe2 and Unsafe3. Allinstructions that are determined to be unsafe i.e. they use unsafe databy calling an unsafe function, are added to a list called Worklist. Aset of concurrent worker threads are spawned, each thread selecting andprocessing an instruction at random from Worklist. Based on the controlflow graph and data flow model earlier created, for each instruction inWorklist, Unsafe1 list is populated with incoming unsafe data at thatinstruction, Unsafe2 list with unsafe data currently being processed bythat instruction, and Unsafe3 list with unsafe data that has been fullyprocessed by that instruction. As the worker threads process theinstructions, the contents of the three lists for each instruction areupdated based on the control flow graph of that instruction as dataflows from its Unsafe1 list to Unsafe2 list to Unsafe3 list and into theUnsafe1 list of the downstream instruction. If new unsafe data is addedto the Unsafe1 list of an instruction that calls an unsafe function, itis re-added to the Worklist and a security finding is generated, and theabove process is repeated. Ultimately, the spawning of worker threads isconcluded when there are no more unsafe instructions left in Worklist,or a predetermined timeout period has elapsed during the aboveprocessing.

Concurrency locks are provided for each of the three lists, Unsafe1,Unsafe2 and Unsafe3 above, and at each step of the above processing,these locks are used to ensure the integrity of the contents of theselists. When a list is no longer being used, its concurrency lock isreleased (unlocked).

In a highly advantageous embodiment, worker threads are distributedacross a multi-core or multi-processor or multi-CPU processingenvironment to improve the performance of the analysis and to allowprocessing of very large target software programs. In a similarlyadvantageous embodiment, the traversal of the control flow graph by theworker threads is performed according to custom unsafe data propagationrules provided by the user. In another advantageous embodiment thesecurity findings are created by an analyzer module.

Clearly, the system and methods of the invention find many advantageousembodiments. The details of the invention, including its preferredembodiments, are presented in the below detailed description withreference to the appended drawing figures.

BRIEF DESCRIPTION OF THE DRAWING FIGURES

FIG. 1 is a block diagram view of the software vulnerabilities detectionsystem according to the current invention.

FIG. 2 is a conceptual diagram of the instruction model according to thecurrent invention.

FIG. 3 is a diagram of the control flow graph of an instructionaccording to the invention.

FIG. 4 is a conceptual diagram of the data flow model of an instructionaccording to the invention.

FIG. 5 is a detailed block diagram view of the elements and theirworkings according to the current invention.

FIG. 6 is a flowchart comprising the analytical steps of the algorithmrequired for the detection of software vulnerabilities according to thecurrent invention.

DETAILED DESCRIPTION

The figures and the following description relate to preferredembodiments of the present invention by way of illustration only. Itshould be noted that from the following discussion, alternativeembodiments of the structures and methods disclosed herein will bereadily recognized as viable alternatives that may be employed withoutdeparting from the principles of the claimed invention.

Reference will now be made in detail to several embodiments of thepresent invention(s), examples of which are illustrated in theaccompanying figures. It is noted that wherever practicable, similar orlike reference numbers may be used in the figures and may indicatesimilar or like functionality. The figures depict embodiments of thepresent invention for purposes of illustration only. One skilled in theart will readily recognize from the following description thatalternative embodiments of the structures and methods illustrated hereinmay be employed without departing from the principles of the inventiondescribed herein.

The present invention will be best understood by first reviewing thesoftware vulnerabilities detection system 100 according to the currentinvention as illustrated in FIG. 1. Vulnerabilities detection system 100comprises computer program 102 in the form of its compiled code 104 andoptionally source code 106 that resulted in its compiled code 104.Computer program 102 is the target program to be analyzed by system 100for software vulnerabilities. Having source code 106 is desirable butnot required by software vulnerabilities detection system 100 accordingto the invention. Vulnerabilities detected by system 100 in computerprogram 102 may allow exploitative attacks by potential adversaries orhackers. Such attacks include, but are not limited to denial of serviceattacks, code injection attacks and 2^(nd) order attacks such ascross-site scripting (XSS) attacks.

Software vulnerabilities detection system 100 comprises instructionmodel 110, control flow graph 112 and data flow model 114. Based oninstruction model 110, control flow graph 112 and data flow model 114,software vulnerabilities detection system 100 performs analysis 116 toproduce security report 118 comprising the security findings discoveredduring analysis 116.

Readers with ordinary skill in the art will understand that compiledcode 104 can be executable binary code, machine code, or object codethat can run directly on a hardware platform such as x86, Sparc, Mac,HP, IBM Mainframe, etc. or it can be an intermediate bytecode orportable code that can run in a given runtime environment such as JavaVirtual Machine (JVM). Source code 106 can be in any programing languagesuch as C, C++, Java, Assembly, Cobol, SQL, etc. Furthermore, sourcecode 106 can be in any 2^(d), 3^(rd), 4^(th) or higher generationprogramming language without departing from the principles of theinvention. A highly advantageous aspect of the current invention is thatsource code 106 is desirable, but not required to achieve the objects ofthe invention. Not requiring the presence of source code 106 overcomesmany practical limitations of the prior art.

Instruction model 110 is a programming construct used by the inventionto model each instruction of compiled code 104. This programmingconstruct comprises all the necessary and desirable attributes requiredby system 100 to model each instruction of compiled code 104. Theseattributes include the location (e.g. base address and relative memorylocation), debug information if available (e.g. variable nameannotations and/or source code line annotations), type of theinstruction (e.g. mov, add, sub), its operands (e.g. eax register, aninteger immediate value, operand stack reference, local valuereference), its potential security attributes and existing memory staterequirements (e.g. basic block derived invariant conditions), basicblock membership (e.g. start and end references for all basic blocksencompassing an instruction), function/method membership and/or classmembership of that instruction if applicable. Those with average skillin the art will find these attributes familiar from the fundamentals ofsoftware engineering and computer programming. FIG. 2 provides aconceptual representation of instruction model 110 using a familiarnotation for data structures and member associations in computerprogramming.

Referring to FIG. 1, during the execution of compiled code 104, userinput 108 may be provided by the operator or user of computer program102 whose vulnerabilities are to be detected. Those familiar with theart will understand that user input 108 represents a potential securityrisk for computer program 102 as it may intentionally or otherwise,violate the bounds of a program variable which may affect the integrityof computer program 102 or the data it is operating on. Thus user input108 represents ‘taint’ or unsafe data, as will be understood by skilledpeople of the art. User input 108 can be provided in many differentways, for example, via a web form and keyboard, a file, an input/outputbuffer or stream, a pipe, screen redirect, etc.

Compiled code 104 according to the invention is preferably instrumentedat random and critical control flow points of the program. Thosefamiliar with the art will understand that instrumentation may refer tocode instructions and metadata augmented to the computer program thatallow monitoring of its behavior, performance and operation more closelythan during normal execution, and may generate additional logging anddebug output to the screen or files as desired. As claimed by theinvention, computer program 102 is preferably instrumented at randompoints within the program. Instead of or in addition to that, theprogram is also preferably instrumented at points where there is acritical control flow transition in the program.

Those familiar with the art will understand that there are many ways todetermine these points where instrumentation will be provided incomputer program 102 in the preferred embodiment. For example,instructions in compiled code 104 can be randomly selected forinstrumentation. Alternatively or in addition, a pre-processor can beused to determine the critical control flow points in program 102 priorto its execution, and then instrumentation can be added at those pointsin program 102. Indeed, it is allowed by the invention to instrumententire or none of computer program 102, without departing from theprinciples of the invention. The instrumentation of program 102 allowsobserving and modification of unsafe data as it flows through program102 according to the teachings of the invention.

The invention further uses control flow graph 112 for each instructionthat complements instruction model 110 of that instruction. Control flowgraph 110 for a given instruction of compiled code 104 is populated withall potential control flow paths of that instruction, assuming there isno overwriting of the underlying instructions. Control flow graph 112for a given instruction also contains a bidirectional list of itspredecessor instructions. FIG. 3 represents control flow graph 114 foran instruction I according to the teachings of the invention. In FIG. 3,each instruction is represented by a circle. Instruction I has 4predecessor instructions P and 3 successor instructions S representingall possible control flow paths for I as shown in the figure. All Pinstructions will be contained in a bidirectional list in control flowgraph 112 for instruction I as represented by the dashed line in FIG. 3.

Referring back to FIG. 1, the invention further comprises data flowmodel 114. During the execution of program 102, the movement of unsafedata is recorded in data flow model 114. As unsafe data moves from onevariable or processor register to another and from one instruction tothe successor instruction, this movement is recorded in data flow model114 according to the teachings of the invention. FIG. 4 represents anexample data flow model 114 populated according to the teachings of theinvention. Variable V1 contains unsafe data that may have beenpreviously supplied by user input 108 as taught earlier. Tainted data V1is then moved to processor register AX in the next instruction of onecontrol flow path, and then copied to variable V2. The subsequentinstruction then calls an unsafe function on variable V2 representing apotential security risk in the computer program. FIG. 4 also illustratesadditional control flow paths in data flow model 114 where the unsafefunction call is performed on the tainted data contained in variable V2.Those familiar with the art will know the various types of unsafefunction calls that may result in a potential security flaw in the codethat can be exploited by an adversary. For example, in C/C++“char*strcpy(char*dest, const char*src)” function on tainted data is anunsafe function call, because it can allow a security condition calledbuffer overflow to happen and damage the integrity of computer program102 of FIG. 1, or its data, or worse allow a malicious adversary toinject harmful code or virus into the computer program.

According to the teachings of the current invention as explained above,data flow model 114 only records the flow of unsafe data during theexecution of the program, as opposed to attempting to include and recordall potential data flows. This significantly reduces the performanceoverhead and memory requirements of software vulnerabilities detectionsystem 100, allowing it to analyze large target software systems morecomprehensively than possible through the teachings of prior art. Thisalso allows the current invention to not require decompilation ofcompiled code, as required by some prior art teachings.

According to the main embodiment of the invention, based on instructionmodel 110, control flow graph 112 and data flow model 114, allinstructions in computer program 102 that call an unsafe function onunsafe data, trigger a security finding which is recorded in securityreport 118 as represented in FIG. 1. Each such security finding containsdebug information of the instruction that triggered the securityfinding, along with its source code information, if available. Securityreport 118 exposes the vulnerabilities in computer program 102 that canbe appropriately remediated to prevent exploitative attacks by amateurand professional adversaries according to the teachings of theinvention.

As represented in FIG. 2, instruction model 110 further includesplaceholders for additional attributes or deduced attributes that maynot be immediately known at the time of the initial creation ofinstruction model 110. These additional attributes may include pointeraliases. Pointer aliases represent pointers that point to, or containmemory addresses, that remain the same for multiple control flow pathsof computer program 102. In addition, instruction model 110 for a giveninstruction I may include information related to its predecessorinstructions P as represented in FIG. 3, and any additional informationor metadata as deemed necessary to facilitate recording of the flow ofunsafe data as represented in FIG. 4. Furthermore, instruction model 110may also include information deduced from other attributes. Examples ofsuch derived attributes include memory locations or addresses, processorregisters and variable type information for the given instruction basedon its type, debug information and bytecode metadata.

According to an additional embodiment of the invention, analysis 116 inFIG. 1 may be performed by an analyzer module. Analyzer module may be apart of system 100 or may be external to it. If it is external to system100, appropriate remote invocation calls or function calls or remoteprocedure calls (RPC) may be implemented to call the external module, aswill be obvious to those skilled in the art. Indeed it is possible thatthe analyzer module is a 3^(rd) party software with its own applicationprogramming interface (API), without departing from the principles ofthe invention. Similarly, in a highly advantageous embodiment, analysis116 is performed by worker threads that are spawned specifically forthat purpose. These worker threads may then be distributed across acluster of computing nodes, processors or cores, in a multi-CPU ormulti-core, parallel processing environment.

Further embodiments claim that security report 118 of FIG. 1 maycomprise an execution trace of unsafe data corresponding to each saidsecurity finding populated in the report. The execution trace maycontain the origin and termination information for the unsafe data thatultimately caused the security finding to be triggered. For example, ifunsafe data was provided as a user input in function or instruction I1and it traversed through several intervening functions or instructionsI2 . . . I9 before being discarded or reset in instruction I10, thenexecution trace for the corresponding security finding in securityreport 118 may contain the entire lifecycle or trace of that data alongwith the names of functions or instructions I1 . . . I10. In addition,security report 118 may contain a human friendly description of thesecurity finding, and a risk rating or risk factor assigned to thesecurity finding by system 100. Depending on the severity of thevulnerability associated with each finding, vulnerabilities detectionsystem 100 may assign a risk rating from 1 to 10, or as a percentage, oruse some other suitable rating system. Security report 118 may alsocontain one or more recommendations on how to address the securityfinding, or ‘fix’ the problem. Such recommendations and risk assignmentsmay be based on a knowledgebase (not shown) derived from subject matterexpertise in detecting and correcting such software vulnerabilities.

The methods of the invention describe the steps required to operatesoftware vulnerabilities detection system 100 of FIG. 1. In thepreferred embodiment, computer program 102 is executed at least once andthe flow of unsafe data through the program is first recorded in a dataflow file 140 as shown in FIG. 4. Based on the contents of data flowfile 140, data flow model 114 is populated. The format of data flow file140 can be any suitable file format, such as XML, plain text, any othermarkup format, or a binary (or compiled) format, without departing fromthe principles of the invention.

In the preferred embodiment, three lists, Unsafe1, Unsafe2, Unsafe3 arecreated for each instruction. Persons with average skill in the art willunderstand that these lists can be linked lists, arrays or any otherappropriate data structures of computer software without departing fromthe principles of the invention. Compiled code 104 is scanned to findeach instruction where an external input is supplied to the program,denoting unknown, unsafe or ‘taint’ data. If that instruction calls anunsafe function on the unsafe data, that instruction is added to anotherlist, Worklist. Persons skilled in the art will again understand thatWorklist can be a linked list, an array or any other suitable datastructure. List Worklist 160, Unsafe1 list 180, Unsafe2 list 184 andUnsafe3 list 186 are shown in FIG. 5 along with the other elements ofthe invention as taught earlier.

Next, a set of concurrent worker threads are spawned, each threadselecting and processing an instruction at random from Worklist 160 ofFIG. 5. Based on instruction model 110, control flow graph 112 and dataflow model 114, for each instruction in Worklist 160, Unsafe1 list 180is populated with incoming unsafe data at that instruction, Unsafe2 list182 with unsafe data currently being processed by that instruction, andUnsafe3 list 184 with unsafe data that has been fully processed by thatinstruction. As the worker threads process the instructions of compiledcode 104, the contents of Unsafe1 list 180, Unsafe2 list 182, Unsafe3list 184 for each instruction are updated based on control flow graph112 of that instruction as data flows from its Unsafe1 list 180 toUnsafe2 list 182 to Unsafe3 list 184 and into Unsafe1 list 180 of thesuccessor instruction.

If new unsafe data is added to Unsafe1 list 180 of an instruction thatcalls an unsafe function, a new security finding 200 is created andadded to security report 118 as represented in FIG. 5, and thatinstruction is re-added to Worklist 160, and the above process isrepeated. Ultimately, the spawning of worker threads is concluded whenthere are no more unsafe instructions left in Worklist 160, or apredetermined timeout period has elapsed during the above processing.FIG. 6 shows the above algorithm in a flowchart format where an unsafeinstruction denotes an instruction that calls an unsafe function onunsafe data as explained above, and the label instr is used toabbreviate the term instruction.

Referring to FIG. 5, concurrency locks 190, 192, 194 are provided foreach of Unsafe1 list 180, Unsafe2 list 182 and Unsafe3 list 184respectively, and at each step of the above processing, these locks areused to ensure the integrity of the contents of these lists. When a listis no longer being used, its concurrency lock is released (unlocked).Those skilled in the art will understand how the contents of Unsafe1list 180, Unsafe2 list 182 and Unsafe3 list 184 will be updated asexplained above. Further explained, when a worker thread selects aninstruction to process from Worklist 160, it locks its Unsafe2 list 182and Unsafe3 list 184, and also temporarily locks its Unsafe1 list 180while it imports data from its Unsafe1 list 180 to Unsafe2 list 182. Theworker thread then statically analyzes the currently selectedinstruction to determine from its incoming unsafe data in Unsafe1 list,currently processed data in Unsafe2 list and fully processed data inUnsafe3 list, what other instructions that unsafe data may propagate to,based on the attributes of the current instruction as contained in itsinstruction model 110, and any other custom unsafe data propagationrules pre-defined or provided by the user.

Examples of custom unsafe data propagation rules include specifying thata function or method, e.g. execSqlStatement(String query), should neverreceive unsafe or “taint” user input in its first and only parameter.Such a rule could be expressed as an XML file defining regularexpressions to identify the specific class and method for this call,along with a numeric value identifying that the first parameter shouldnever be tainted or uncontrolled, along with security informationdefining the security impact of such a condition. Another example wouldbe a rule which identifies that the subString(Integer from) call willpropagate the value of its object instance to its return value, whichcould be similarly expressed in an xml file, and identifying the returnvalue. Still other examples of custom rules include source rules, whichdefine the insertion of uncontrolled or tainted data into a program andcleanse rules which define methods that are known to control data suchthat the data can afterwards be considered safe in one or more ways.

Referring back to FIG. 5 and preceding teachings, based on control flowgraph 112 of the current instruction, the current worker threadaggregates all possible control flow destinations of the currentinstruction in a list Next Instructions (not shown). Subsequently, foreach instruction in Next Instructions list, the current worker threadlocks its Unsafe1 list and adds outgoing processed unsafe data containedin Unsafe3 list 184 of current instruction, to incoming unsafe datacontained in Unsafe1 list 180 of the instruction selected from NextInstructions list. As explained above, if unsafe data is added toUnsafe1 list of an instruction that calls an unsafe function, a securityfinding 200 is added to security report 118 and that instruction isre-added to Worklist 160. The above process continues until there are nomore instructions left to process in Worklist 160 or a timeout periodhas elapsed.

In a highly advantageous embodiment, worker threads are distributedacross a multi-core or multi-CPU or multi-machine or multi-nodeprocessing environment to improve the performance of the analysis and toallow processing of very large target software programs. In a similarlyadvantageous embodiment, the traversal of the control flow graph by theworker threads is performed according to custom unsafe data propagationrules provided by the user. In another advantageous embodiment thesecurity findings are created by an analyzer module.

In another advantageous embodiment, security report 118 as shown in FIG.5 contains a full execution trace of unsafe data corresponding to eachsecurity finding 200 populated in security report 118. The executiontrace may contain the origin and termination information for the unsafedata that ultimately caused security finding 200 to be triggered. Forexample, if unsafe data was provided as a user input in function orinstruction I1 and it traversed through several intervening functions orinstructions I2 . . . I9 before being discarded or reset in instructionI10, then execution trace for corresponding security finding 200 insecurity report 118 may contain the entire lifecycle or trace of thatdata along with the names or labels of instructions I1 . . . I10 alongwith filename or filenames and corresponding line numbers in the sourcefiles obtained from debug information or assembly instructions or sourcecode 106 if available. If source code 106 is available, each source filecorresponding to the above trace is parsed into an abstract syntax treeor trees, and the line numbers and offsets for non-keyword identifiertokens is generated. Persons skilled in the art will understand thatthese non-keyword identifier tokens will represent user or customvariables, as opposed to keywords belonging to the grammar of theprogramming language itself. Using the abstract syntax tree or treesabove, corresponding to each instruction in the trace, the identifiernames and values of any variables or processor registers that containedthe unsafe data is obtained using the debug information and added to thetrace information.

In addition, security report 118 of FIG. 5 may be properly formatted tobe visually appealing with proper highlighting of important pieces ofinformation for each security finding 200, and contain a human friendlydescription of the finding along with a risk rating or risk factorassigned to the finding by system 100. Depending on the severity of thevulnerability associated with each security finding 200, vulnerabilitiesdetection system 100 may assign a risk rating from 1 to 10, or as apercentage, or use some other suitable rating system. Security report118 may also contain one or more recommendations on how to addresssecurity finding 200, or ‘fix’ the problem. Such recommendations andrisk assignments may be based on a knowledgebase (not shown) derivedfrom subject matter expertise in detecting and correcting such softwarevulnerabilities. The knowledgebase may be further designed tocontinuously augment its content either automatically or with humanassistance or by a combination of both automatic and manual means, asvulnerabilities detection system 100 operates over time.

In view of the above teaching, a person skilled in the art willrecognize that the apparatus and method of invention can be embodied inmany different ways in addition to those described without departingfrom the principles of the invention. Therefore, the scope of theinvention should be judged in view of the appended claims and theirlegal equivalents.

I claim:
 1. A software vulnerabilities detection system comprising: a)compiled code and optionally source code that resulted in said compiledcode; b) an instruction model for each instruction of said compiled codecomprising location, debug information, instruction type, operands,existing memory state requirements, bytecode metadata, potentialsecurity attributes, basic block membership, function/method membershipif applicable and class membership of each said instruction; c) acontrol flow graph for each said instruction comprising all potentialcontrol flow paths, and a bidirectional list of predecessor instructionsfor each said instruction; d) a data flow model comprising recorded flowof unsafe data as observed during the execution of said compiled code;e) means for analyzing said instruction model, said control flow graphand said data flow model to create a security finding for each saidinstruction that calls an unsafe function on said unsafe data; and f) asecurity report comprising each said security finding with correspondingsaid debug information and said source code information if available. 2.The software vulnerabilities detection system of claim 1 wherein saidcompiled code is instrumented.
 3. The software vulnerabilities detectionsystem of claim 2 wherein said instrumentation is done at random andcritical control flow points of said compiled code.
 4. The softwarevulnerabilities detection system of claim 1 wherein said instructionmodel further comprises placeholders for additional attributes,including pointer aliasing information and unsafe dataflow information.5. The software vulnerabilities detection system of claim 4 wherein saidpointer aliasing information comprises aliasing maps to determine whichpointers may represent the same value given a plurality of control flowsof each said instruction.
 6. The software vulnerabilities detectionsystem of claim 1 wherein said instruction model further comprisesattributes deduced from other attributes, including values for memory,register and variable type of each said instruction.
 7. The softwarevulnerabilities detection system of claim 1 further comprising a dataflow file recording flow of unsafe data as it flows during the executionof said compiled code.
 8. The software vulnerabilities detection systemof claim 1 further comprising an analyzer module.
 9. The softwarevulnerabilities detection system of claim 1 further comprising a set ofconcurrent worker threads, each thread processing an instruction fromsaid compiled code where an external input is supplied.
 10. The softwarevulnerabilities detection system of claim 9 wherein said concurrentworker threads are executed across one or more selections from the groupconsisting of CPU, processor, core, computing machine and node.
 11. Thesoftware vulnerabilities detection system of claim 1 wherein saidsecurity report further comprises an execution trace of said unsafe datacorresponding to each said security finding, said execution tracecomprising information from the origin to the termination of said unsafedata, and the associated line numbers from said source code information.12. The software vulnerabilities detection system of claim 1 whereinsaid security report further comprises a risk rating, a human-readabledescription and optionally one or more remediation recommendations, foreach said security finding.
 13. A method of detecting softwarevulnerabilities comprising the steps of: a) inputting compiled code andoptionally source code that resulted in said compiled code; b) creatingan instruction model for each said instruction comprising location,debug information, instruction type, operands, existing memory staterequirements, bytecode metadata, potential security attributes, basicblock membership, function/method membership if applicable and classmembership of each said instruction; c) creating a control flow graphassociated with each said instruction model, comprising all potentialcontrol flow paths, and a bidirectional list of predecessor instructionsfor each said instruction; d) creating and populating a data flow model;e) creating a security finding for each said instruction that calls anunsafe function on unsafe data; and f) generating a security reportcomprising said debug information and said source code information foreach said security finding.
 14. The method of detecting softwarevulnerabilities of claim 13 wherein said instruction model is furtherprovided with placeholders for additional attributes, including pointeraliasing information and unsafe dataflow information.
 15. The method ofdetecting software vulnerabilities of claim 14 wherein said pointeraliasing information comprises aliasing maps that are populated withpointers representing the same value given at least two control flows ofeach said instruction of said compiled code.
 16. The method of detectingsoftware vulnerabilities of claim 13 wherein said instruction model isfurther provided with attributes deduced from other attributes,including values for memory, register and variable type of each saidinstruction.
 17. The method of detecting software vulnerabilities ofclaim 13 wherein said population of said data flow model is performed byrunning said compiled code at least once and recording flow of unsafedata for each said run.
 18. The method of detecting softwarevulnerabilities of claim 13 wherein said population of said data flowmodel is based at least partially on a data flow file in which flow ofunsafe data during the execution of said compiled code has beenrecorded.
 19. The method of detecting software vulnerabilities of claim13 wherein said compiled code is further instrumented at random andcritical control flow points allowing observing and modification ofproperties of data as it flows during the execution of said compiledcode.
 20. The method of detecting software vulnerabilities of claim 13further comprising the steps of: a) creating three lists Unsafe1,Unsafe2, Unsafe3 for each said instruction; b) scanning said compiledcode to determine locations where external input is supplied and markingsaid locations as containing unsafe data, and further creating aWorklist of all instructions at said locations that call an unsafefunction; c) creating a set of concurrent worker threads, each threadselecting an instruction at random from said Worklist, and processing itaccording to said control flow graph, and said data flow model, andpopulating said Unsafe1 list with incoming unsafe data at saidinstruction, Unsafe2 list with unsafe data currently being processed bysaid instruction, and Unsafe3 list with unsafe data that has been fullyprocessed by said instruction; d) adding an instruction to said Worklistin step(c) above if said instruction has new data added to its saidUnsafe1 list and said instruction further calls an unsafe function, andrepeating step (c); and e) concluding said creation of said workerthreads if all instructions in said Worklist have been processed asspecified in steps (c) and (d), or a predetermined time has elapsed. 21.The method of detecting software vulnerabilities of claim 20 furthercreating a concurrency lock for each said list Unsafe1, Unsafe2 andUnsafe3.
 22. The method of detecting software vulnerabilities of claim21 further applying said concurrency locks to ensure integrity of saiddata populated in said lists Unsafe1, Unsafe2, Unsafe3.
 23. The methodof detecting software vulnerabilities of claim 21 releasing each saidconcurrency lock corresponding to each said list Unsafe1, Unsafe2 andUnsafe3, if said list is not in use.
 24. The method of detectingsoftware vulnerabilities of claim 20 wherein step 20(c) is furtherperformed according to custom unsafe data propagation rules provided byuser.
 25. The method of detecting software vulnerabilities of claim 13wherein said security finding is created by analyzing said data flowmodel.
 26. The method of detecting software vulnerabilities of claim 13wherein said security report is further provided with an execution traceof said unsafe data corresponding to each said security finding, saidexecution trace comprising information from the origin to thetermination of said unsafe data, derived from said data flow model andthe associated line numbers from said source code information.
 27. Themethod of detecting software vulnerabilities of claim 26 wherein saidexecution trace further comprises the identifier value of any registeror variable containing said unsafe data.
 28. The method of detectingsoftware vulnerabilities of claim 27 wherein said security reporthighlights at least one said identifier and variable associated withsaid unsafe data.
 29. The method of detecting software vulnerabilitiesof claim 13 wherein said security report is further provided with a riskrating, a human-readable description of each said security finding andone or more remediation recommendations for each said security finding.29. The method of detecting software vulnerabilities of claim 13 whereinsaid concurrent worker threads are executed across at least one CPU orprocessor or core or computing machine or node.